/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author David
 */
@Entity
@Table(name = "abonat")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Abonat.findAll", query = "SELECT a FROM Abonat a"),
    @NamedQuery(name = "Abonat.findById", query = "SELECT a FROM Abonat a WHERE a.id = :id"),
    @NamedQuery(name = "Abonat.findByDataAbonat", query = "SELECT a FROM Abonat a WHERE a.dataAbonat = :dataAbonat"),
    @NamedQuery(name = "Abonat.findByQuantitat", query = "SELECT a FROM Abonat a WHERE a.quantitat = :quantitat")})
public class Abonat implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "data_abonat")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataAbonat;
    @Basic(optional = false)
    @Column(name = "quantitat")
    private int quantitat;
    @JoinColumn(name = "mode_aplicacio_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private ModeAplicacio modeAplicacioId;
    @JoinColumn(name = "produccio_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Produccio produccioId;
    @JoinColumn(name = "abono_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Abono abonoId;

    public Abonat() {
    }

    public Abonat(Integer id) {
        this.id = id;
    }

    public Abonat(Integer id, Date dataAbonat, int quantitat) {
        this.id = id;
        this.dataAbonat = dataAbonat;
        this.quantitat = quantitat;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataAbonat() {
        return dataAbonat;
    }

    public void setDataAbonat(Date dataAbonat) {
        this.dataAbonat = dataAbonat;
    }

    public int getQuantitat() {
        return quantitat;
    }

    public void setQuantitat(int quantitat) {
        this.quantitat = quantitat;
    }

    public ModeAplicacio getModeAplicacioId() {
        return modeAplicacioId;
    }

    public void setModeAplicacioId(ModeAplicacio modeAplicacioId) {
        this.modeAplicacioId = modeAplicacioId;
    }

    public Produccio getProduccioId() {
        return produccioId;
    }

    public void setProduccioId(Produccio produccioId) {
        this.produccioId = produccioId;
    }

    public Abono getAbonoId() {
        return abonoId;
    }

    public void setAbonoId(Abono abonoId) {
        this.abonoId = abonoId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Abonat)) {
            return false;
        }
        Abonat other = (Abonat) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Abonat[ id=" + id + " ]";
    }
    
}
